unit uFuncs.local;

interface

type
  TSecondsToTime = class( TObject )
  public
    Hours        : integer;
    Minutes      : integer;
    Seconds      : real;

    function Convert(nSeconds:real):string;
  end;

  function ToPercentage(Number:integer):real;

implementation

uses Math, uFuncs.common, SysUtils;

//======== SecondsToTime
// Converts seconds in to time format string
//==============================================
function TSecondsToTime.Convert(nSeconds:real):string;
begin
  Hours    := (floor(nSeconds) div 3600);
  nSeconds := nSeconds - (hours*3600);

  Minutes  := (floor(nSeconds) div 60);
  nSeconds := nSeconds - (Minutes*60);

  Seconds := nSeconds;

       if (Hours   > 0) then Convert := AddLeadingZeroes(Hours,2,'0',TRUE)+'h'+AddLeadingZeroes(Minutes,2,'0',TRUE)+'m'+FormatFloat('00.000', Seconds)
  else if (Minutes > 0) then Convert := AddLeadingZeroes(Minutes,2,'0',TRUE)+'m'+FormatFloat('00.000', Seconds)
  else Convert := FormatFloat('0.000', Seconds);
end;

function ToPercentage(Number:integer):real;
begin
  result := Number / 100;
end;

end.
